#ifndef DDCPMESSAGE_HPP__
#define DDCPMESSAGE_HPP__

#include <list>
#include "DDCPItem.hpp"
#include "DDCPItemTypes.hpp"


/**
 *  class: 
 *  purpose: 
 *  brief: 
 *
 *  details: 
 */
class  CDDCPMessage: public CDDCPItemHandle{
public:
    CDDCPMessage();

    CDDCPMessage( const char* start );

    virtual ~CDDCPMessage();

    ////////////////////////////////CDDCPItemHandle Methos/////////////////////////////////////
    virtual CDDCPItemHandle& addItem( const char* itmName, uint32_t length );

    virtual CDDCPItemHandle& addItem( CDDCPItemTypes::EDDCPType type ){
        return CDDCPItemHandle::addItem( type );
    }

    virtual CDDCPItemHandle& itemDo( const char* itmName, uint32_t length );

    virtual CDDCPItemHandle& itemDo( CDDCPItemTypes::EDDCPType type ){
        return CDDCPItemHandle::itemDo( type );
    }

    virtual  CDDCPItemHandle& child();

    virtual CDDCPItemHandle& item( const char* itmName, uint32_t length );

    virtual CDDCPItemHandle& item( CDDCPItemTypes::EDDCPType type ){
        return CDDCPItemHandle::item( type );
    }

    virtual bool isMessage();

    virtual bool isElement();

    //////////////////////////////////////////////////////////////////////////////
    bool parseData( const char* input );

    const char* cStr();

    bool clear();

    CDDCPItemTypes::EDDCPType getMsgType();

    bool addDeclaration( const char* version=s_version, const char* encoding="", const char* standalone="" );

    bool saveFile( const char* xmlFile );

    virtual const char* getValue( const char* name );
    
    virtual const char* getText();

    virtual void itemList( const char * type, uint32_t length, std::list<CDDCPItemHandle*>&typelist );

    virtual void itemList( CDDCPItemTypes::EDDCPType type, std::list<CDDCPItemHandle*>& typelist );

    virtual void setText(const char* text);
     
protected:

    bool removeNode( TiXmlNode* node );

    CDDCPItemHandle* findNode( TiXmlNode* node );

    TiXmlNode* getItem();

private:

     bool updateType();

private:

    static const char* s_version;

    TiXmlPrinter* m_printer;

    TiXmlDocument m_xmlDoc;

    //std::list<CDDCPItemHandle*> m_items;

    CDDCPItemTypes::EDDCPType m_type;

    bool m_updated;
};

#endif

